package com.fiberhome.boot.demo.thirdary.Controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.fiberhome.boot.demo.thirdary.dao.ThirdaryRepository;
import com.fiberhome.boot.demo.thirdary.domain.UserInfo;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping(value="/sqlserver")
@Api(value = "sqlserver数据源测试", description="sqlserver数据源测试", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class SqlServerController {

	@Autowired
	ThirdaryRepository dao;
	
	
	@ApiOperation(value="用户列表", notes="用户列表")
	@RequestMapping(value="/userinfos",method=RequestMethod.GET)
	public Iterable<UserInfo> getAll(){
		return dao.findAll();
	}
	
	@ApiOperation(value="保存用户", notes="保存用户")
	@RequestMapping(value="/saveUser",method=RequestMethod.POST)
	public String saveUsers(@RequestBody UserInfo user){
		dao.save(user);
		return "save sucusess";
	}
}
